/*
 * @Author: 灰灰
 * @Date: 2021-12-26 17:17:06
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-12-26 17:26:58
 */

import request from '@/utils/request';

// 将参数转成formData数据
function paramsToFormData(data) {
  const formData = new FormData();
  for (let key in data) {
    formdata.append(key, data[key]);
  }
  return formData;
}

// get 请求
export function getRequest(url, data) {
  return request({
    url: url,
    method: 'get',
    params: data
  })
}

// get 请求  参数formaData数据
export function getFormDataRequest(url, data) {
  data = paramsToFormData(data);
  return request({
    url: url,
    method: 'get',
    params: data
  })
}

// post 请求
export function postRequest(url, data) {
  return request({
    url: url,
    method: 'post',
    data
  })
}

// post 请求  参数formaData数据
export function postFormDataRequest(url, data) {
  data = paramsToFormData(data);
  return request({
    url: url,
    method: 'post',
    data
  })
}

// put 请求
export function putRequest(url, data) {
  return request({
    url: url,
    method: 'put',
    params: data,
    data
  })
}

// 删除
export function delRequest(url, data) {
  return request({
    url: url,
    method: 'delete',
    params: data,
    data
  })
}